using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
/// <summary>
/// toolData
/// </summary>
[Serializable]
public class toolData {
        /// <summary>
        /// 道具编号
        /// </summary>
        public int id;
        /// <summary>
        /// 道具名
        /// </summary>
        public String name;
        /// <summary>
        /// 图片
        /// </summary>
        public String img;
        /// <summary>
        /// 层级
        /// </summary>
        public int zIndex;
        /// <summary>
        /// 是否有方向
        /// </summary>
        public bool hasDirection;
        /// <summary>
        /// 占用格数
        /// </summary>
        public string occupy;
        /// <summary>
        /// 是否有数量
        /// </summary>
        public bool hasCount;
}
/// <summary>
/// Config
/// </summary>
[Serializable]
public class ConfigData
{
	public Dictionary<int, toolData> toolData;
    public int[] toolDataKeyList = {1,2,3,4,5,24,20,6,7,8,9,10,11,12,13,14,15,16,17,18,19,21,22,23 };
}
public class MyJson
{
	public static ConfigData config;
	public static void Init()
	{
		string str = ReadFromStreamAssets("myJson.json");
		config = JsonConvert.DeserializeObject<ConfigData>(str);
	}
    private static string ReadFromStreamAssets(string jsonFilePath)
    {
        var fullPath = GetFilePathOfStreamingAssetsPath(jsonFilePath);
#if UNITY_ANDROID && !UNITY_EDITOR
            WWW www = new WWW(fullPath);
            if (www.error != null) {
                Debug.LogError("error : " + fullPath);
                return "";
            }
            while (!www.isDone) { }
            return www.text;
#else
        StreamReader reader = new StreamReader(fullPath);
        if (reader != null) {
            var ret = reader.ReadToEnd();
            reader.Close();
            return ret;
        } else {
            throw new System.Exception();
        }
#endif
    }
    private static string GetFilePathOfStreamingAssetsPath(string filePath)
    {
        return UnityEngine.Application.streamingAssetsPath + Path.DirectorySeparatorChar + filePath;
    }
}